<!DOCTYPE html>
<html lang="">

<head>
	<meta name="generator" content="Hugo 0.73.0" />
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="author" content="Ap Chen ">
<meta name="description" content="解决如何评价关系模式设计的好坏和如何设计性能良好的关系模式的问题 关系设计模式：同一个关系数据库系统可以有多种关系模式设计方案 好方案：既有合理" />
<meta name="keywords" content="blog" />
<meta name="robots" content="noodp" />

<link rel="canonical" href="https://fziks.gitee.io/notes/database/4-%E8%A7%84%E8%8C%83%E5%8C%96%E7%90%86%E8%AE%BA/" />

<meta itemprop="name" content="4-规范化理论">
<meta itemprop="description" content="解决如何评价关系模式设计的好坏和如何设计性能良好的关系模式的问题 关系设计模式：同一个关系数据库系统可以有多种关系模式设计方案 好方案：既有合理">
<meta itemprop="datePublished" content="2019-05-26T00:00:00&#43;00:00" />
<meta itemprop="dateModified" content="2019-05-26T00:00:00&#43;00:00" />
<meta itemprop="wordCount" content="1339">



<meta itemprop="keywords" content="" />
<meta property="og:title" content="4-规范化理论" />
<meta property="og:description" content="解决如何评价关系模式设计的好坏和如何设计性能良好的关系模式的问题 关系设计模式：同一个关系数据库系统可以有多种关系模式设计方案 好方案：既有合理" />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://fziks.gitee.io/notes/database/4-%E8%A7%84%E8%8C%83%E5%8C%96%E7%90%86%E8%AE%BA/" />
<meta property="article:published_time" content="2019-05-26T00:00:00+00:00" />
<meta property="article:modified_time" content="2019-05-26T00:00:00+00:00" />

<meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="4-规范化理论"/>
<meta name="twitter:description" content="解决如何评价关系模式设计的好坏和如何设计性能良好的关系模式的问题 关系设计模式：同一个关系数据库系统可以有多种关系模式设计方案 好方案：既有合理"/>


<link rel="apple-touch-icon" sizes="60x60" href="https://fziks.gitee.io/icons/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="https://fziks.gitee.io/icons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="https://fziks.gitee.io/icons/favicon-16x16.png">
<link rel="manifest" href="https://fziks.gitee.io/icons/site.webmanifest">
<link rel="mask-icon" href="https://fziks.gitee.io/icons/safari-pinned-tab.svg" color="#5bbad5">
<link rel="shortcut icon" href="https://fziks.gitee.io/icons/favicon.ico">
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-config" content="/icons/browserconfig.xml">
<meta name="theme-color" content="#ffffff">

<title>4-规范化理论</title>


<link rel="stylesheet" href="//at.alicdn.com/t/font_1559566_wk214kwa2dn.css">


    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.css" integrity="sha384-zB1R0rpPzHqg7Kpt0Aljp8JPLqbXI3bhnPWROx27a9N0Ll6ZP/+DiW/UqRcLbRjq" crossorigin="anonymous">



    
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.css" integrity="sha256-WAgYcAck1C1/zEl5sBl5cfyhxtLgKGdpI3oKyJffVRI=" crossorigin="anonymous" />
    
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.2/animate.css" integrity="sha256-a2tobsqlbgLsWs7ZVUGgP5IvWZsx8bTNQpzsqCSm5mk=" crossorigin="anonymous" />
    
   <link href="https://stackpath.bootstrapcdn.com/bootswatch/4.4.1/materia/bootstrap.min.css" rel="stylesheet" integrity="sha384-1tymk6x9Y5K+OF0tlmG2fDRcn67QGzBkiM3IgtJ3VrtGrIi5ryhHjKjeeS60f1FA" crossorigin="anonymous">
    
    
    <link rel="stylesheet" href="https://fziks.gitee.io/sass/main_cdn.min.270b43bb8631af4497ed45b90db42c517e86c9511418de9152f134d02ed32b87.min.2192baea245cf318085511589e62bfbdb3fbe4fb0eef718f1be9af91c10542ce.css" integity="sha256-IZK66iRc8xgIVRFYnmK/vbP75PsO73GPG&#43;mvkcEFQs4=">

</head>

<body style="overflow-x: unset;">
	<div class="container-fluid">
		<div class="row d-print-block">
			<div class="col-12 col-md-3 col-lg-2 bd-sidebar d-print-none">
				<div class="d-flex mt-3 border-bottom">
        <span class="navbar-brand w-100" style="display: grid;">
            <small>
                <a href="https://fziks.gitee.io/" class="text-black-50">
                    <i class="iconfont icon-back-arrow-"></i>
                </a>
                Ap Chen's
            </small>
            <a class="text-dark" href="https://fziks.gitee.io/notes/">
                Notes
            </a>
        </span>
        <button class="btn btn-link text-dark d-md-none p-0 ml-3" type="button" data-toggle="collapse"
            data-target="#bd-docs-nav" aria-controls="bd-docs-nav" aria-expanded="true"
            aria-label="Toggle docs navigation">
            <i class="fad fa-bars"></i>
        </button>
    </div>
				<nav id="bd-docs-nav" class="collapse bd-links">
    
    
    
    <div class="bd-toc-item">
        <a class="bd-toc-link" href="https://fziks.gitee.io/notes/computer-network/">
            
            
                <span class="icontext">S</span>
            
            
            计算机网络
        </a>
    </div>
    
    
    
    <div class="bd-toc-item">
        <a class="bd-toc-link" href="https://fziks.gitee.io/notes/operating-system/">
            
            
                <span class="icontext">S</span>
            
            
            操作系统
        </a>
    </div>
    
    
    
    <div class="bd-toc-item active bg-light">
        <a class="bd-toc-link" href="https://fziks.gitee.io/notes/database/">
            <i class="iconfont icon-back-arrow-reverse"></i>
            数据库
        </a>
        <ul class="nav bd-sidenav">
            
            
            <li>
                <a href="https://fziks.gitee.io/notes/database/1-%E6%A6%82%E8%BF%B0/">1-概述</a>
            </li>
            
            
            
            <li>
                <a href="https://fziks.gitee.io/notes/database/2-%E6%95%B0%E6%8D%AE%E6%A8%A1%E5%9E%8B/">2-数据模型</a>
            </li>
            
            
            
            <li>
                <a href="https://fziks.gitee.io/notes/database/3-%E5%85%B3%E7%B3%BB%E6%95%B0%E6%8D%AE%E5%BA%93%E7%B3%BB%E7%BB%9F/">3-关系数据库系统</a>
            </li>
            
            
            
            <li class="active">
                <a href="https://fziks.gitee.io/notes/database/4-%E8%A7%84%E8%8C%83%E5%8C%96%E7%90%86%E8%AE%BA/">
                    <i class="fad fa-chevron-right mr-1"></i>
                    4-规范化理论
                </a>
            </li>
            
            
            
            <li>
                <a href="https://fziks.gitee.io/notes/database/5-%E5%AE%89%E5%85%A8%E6%80%A7%E4%B8%8E%E5%AE%8C%E6%95%B4%E6%80%A7/">5-安全性与完整性</a>
            </li>
            
            
            
            <li>
                <a href="https://fziks.gitee.io/notes/database/6-%E4%BA%8B%E5%8A%A1%E5%A4%84%E7%90%86/">6-事务处理</a>
            </li>
            
            
            
            <li>
                <a href="https://fziks.gitee.io/notes/database/7-%E6%95%B0%E6%8D%AE%E5%BA%93%E7%9A%84%E7%89%A9%E7%90%86%E7%BB%84%E7%BB%87/">7-数据库的物理组织</a>
            </li>
            
            
            
            <li>
                <a href="https://fziks.gitee.io/notes/database/8-%E6%95%B0%E6%8D%AE%E4%BA%A4%E6%8D%A2/">8-数据交换</a>
            </li>
            
            
            
            <li>
                <a href="https://fziks.gitee.io/notes/database/9-%E6%95%B0%E6%8D%AE%E5%BA%93%E8%AE%BE%E8%AE%A1/">9-数据库设计</a>
            </li>
            
            
        </ul>
    </div>
    
    
    
    <div class="bd-toc-item">
        <a class="bd-toc-link" href="https://fziks.gitee.io/notes/cs50-introduction-to-computer-science/">
            
            
                <span class="icontext">S</span>
            
            
            CS50 MIT
        </a>
    </div>
    
    
    
    <div class="bd-toc-item">
        <a class="bd-toc-link" href="https://fziks.gitee.io/notes/software-enginerring/">
            
            
                <span class="icontext">E</span>
            
            
            软件工程
        </a>
    </div>
    
    
    
    <div class="bd-toc-item">
        <a class="bd-toc-link" href="https://fziks.gitee.io/notes/advanced-programming/">
            
            
                <span class="icontext">A</span>
            
            
            高级程序设计
        </a>
    </div>
    
    
    
    <div class="bd-toc-item">
        <a class="bd-toc-link" href="https://fziks.gitee.io/notes/deep-learning/">
            
            
                <span class="icontext">O</span>
            
            
            深度学习基础
        </a>
    </div>
    
    
    
    <div class="bd-toc-item">
        <a class="bd-toc-link" href="https://fziks.gitee.io/notes/%E6%96%87%E7%8C%AE%E7%AE%A1%E7%90%86%E4%B8%8E%E4%BF%A1%E6%81%AF%E5%88%86%E6%9E%90/">
            
            
                <span class="icontext">O</span>
            
            
            文献管理与信息分析
        </a>
    </div>
    
    
</nav>
			</div>
			<div class="col-12 col-md-9 col-lg-10 d-print-block">
				<div class="row d-print-block">
					<main class="col-12 col-md-10 col-lg-9 py-md-3 pl-md-5 bd-content d-print-block" role="main">
						<div id="title" class="my-4 border-bottom">
							<span>数据库</span>
							<h2>4-规范化理论</h2>
							<footer>
								<span>
									<i class="iconfont icon-NewFile mr-2"></i>
									2019-05-26 08:00 CST
								</span> <br />
								<span>
									<i class="iconfont icon-modify mr-2"></i>
									2019-05-26 08:00 CST
								</span> <br />
								<span>
									<i class="iconfont icon-copyright mr-2"></i>
									CC BY-NC 4.0
								</span>
							</footer>
						</div>
						<div id="content" class="hl-h2">
							
							
							
							
							
							
							
							
							
							
							
							
							<p>解决如何评价关系模式设计的好坏和如何设计性能良好的关系模式的问题</p>
<ul>
<li>关系设计模式：同一个关系数据库系统可以有多种关系模式设计方案
<ul>
<li>好方案：既有合理的数据冗余度，又没有插入和删除等操作异常现象</li>
</ul>
</li>
<li>关系数据模型设计方法：建模(E-R model)，转换(set of tables)，规范化</li>
</ul>
<h2 id="函数依赖fdfunctional-dependency">函数依赖（FD,Functional Dependency）<a href="#函数依赖fdfunctional-dependency" class="anchor" aria-hidden="true"><i class="iconfont icon-link"></i></a></h2>
<p>给定关系 $R$，$X,Y$ 是 $R$ 两个属性子集，在关系 $R$ 中，每一个 $X$ 值都有唯一的一个 $Y$ 值与之对应</p>
<ul>
<li>$Y$ 函数依赖 $X$
<ul>
<li>$X$ 函数决定 $Y$($X\rightarrow Y$)</li>
<li>关系 $R$ 满足函数依赖 $X\rightarrow Y$</li>
<li>决定因素：$X$</li>
<li>依赖因素：$Y$</li>
</ul>
</li>
<li>只能证否，不能证明</li>
<li>平凡函数依赖： $Y\not\subseteq X$</li>
<li>完全函数依赖 $X\overset{f}{\rightarrow} Y$：$X\rightarrow Y,\forall X'\subsetneq X,X'\not\rightarrow Y$
<ul>
<li>部分函数依赖 $X\overset{p}{\rightarrow}Y$</li>
</ul>
</li>
<li>传递函数依赖：$X\rightarrow Y,Y\not\rightarrow X,Y\rightarrow Z$, 则 $Z$ 传递函数依赖于 $X$</li>
<li>Armstrong 公理系统：<strong>寻找所有函数依赖</strong>
<ul>
<li>基本规则
<ul>
<li>Reflexivity: $Y\subset X\Rightarrow X\rightarrow Y$</li>
<li>Augmentation: $X\rightarrow Y\Rightarrow X\cup Z\rightarrow Y\cup Z$</li>
<li>Transtivity: $X\rightarrow Y,Y\rightarrow Z\Rightarrow X\rightarrow Z$</li>
</ul>
</li>
<li>扩充规则
<ul>
<li>Union: $X\rightarrow Y\cup Z\Rightarrow X\rightarrow Y,X\rightarrow Z$</li>
<li>Decomposition: $X\rightarrow Y,X\rightarrow Z\Rightarrow X\rightarrow Y\cup Z$</li>
<li>Pseudo transitivity: $X\rightarrow Y,W\cup Y\rightarrow Z\Rightarrow W\cup X\rightarrow Z$</li>
</ul>
</li>
<li>逻辑蕴含：$F\vDash X\rightarrow Y,F$ 为一个函数依赖集</li>
<li>函数依赖集的闭包：$F^+={X\rightarrow Y|F\vDash X\rightarrow Y}$</li>
</ul>
</li>
<li>关键字（码,key）：$R(U,F),K\subset U,K$ 完全函数决定 $U$
<ul>
<li>主属性集：$R$ 的所有关键字中的属性构成的集合</li>
<li>非主属性集</li>
</ul>
</li>
<li>属性集 $X$ 的闭包：$X_F^+={A|F\vDash X\rightarrow A}$
<ul>
<li>计算闭包
<ul>
<li>while $X$ changes
<ul>
<li>for each $Y\rightarrow Z\in F$
<ul>
<li>if $Y\subset X,X=X\cup Z$</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li>关键字 $K$
<ul>
<li>$K_F^+=U$</li>
<li>$\forall Z\subsetneq K,Z_F^+\neq U$</li>
</ul>
</li>
</ul>
</li>
<li><strong>计算关键字</strong>
<ul>
<li>法一：$F\vDash K\overset{f}{\rightarrow} U$</li>
<li>法二
<ul>
<li>$K=U$</li>
<li>for $A\in K$
<ul>
<li>if $(K-A)_F^+$ contains all attribute then $K=K-A$</li>
</ul>
</li>
<li>优化：最小函数依赖集只在左边出现过的属性是主属性，只在右边出现过的属性为非主属性</li>
</ul>
</li>
</ul>
</li>
<li>函数依赖集的等价：$F_1^+=F_2^+$</li>
<li>最小函数依赖集（最小覆盖）
<ul>
<li>判定方法：对于每个关系 $X\rightarrow A$ 需满足以下三条
<ul>
<li>$A$ 为单个属性</li>
<li>$(F-{X\rightarrow A}))^+\neq F^+$</li>
<li>$\forall Y\subset X,(F-{X\rightarrow X,Y\rightarrow A})^+\neq F^+$</li>
</ul>
</li>
<li><strong>计算方法</strong>
<ul>
<li>$G=F$，将 $G$ 中每个 $X\rightarrow(A_1,\cdots,A_n)$ 的函数依赖替换为 $X\rightarrow A_1,\cdots,X\rightarrow A_n$</li>
<li>消除部分函数依赖：对每个函数依赖 $X\rightarrow A$
<ul>
<li>对 $X$ 中每个属性 $B$
<ul>
<li>若 $A\in(X-B)_G^+$, 则用 $(X-B)\rightarrow A$ 替换 $X\rightarrow A$</li>
</ul>
</li>
</ul>
</li>
<li>消除冗余函数依赖：对每个函数依赖 $X\rightarrow A$
<ul>
<li>若 $A\in X_N^+,N=G-{X\rightarrow A}$ 则从 $G$ 中删去 $X\rightarrow A$</li>
</ul>
</li>
<li>将 $X\rightarrow A_1,\cdots,X\rightarrow A_n$ 合并为 $X\rightarrow(A_1,\cdots,A_n)$</li>
</ul>
</li>
</ul>
</li>
</ul>
<h2 id="多值依赖-mvd">多值依赖 (MVD)<a href="#多值依赖-mvd" class="anchor" aria-hidden="true"><i class="iconfont icon-link"></i></a></h2>
<ul>
<li>$X\rightarrow\rightarrow Y$: $X$ 与 $Y$ 的一组值对应，且 $Y$ 的这组值与 $U-X-Y$ 无关</li>
<li>非平凡的多值依赖：$U-X-Y\neq\emptyset$</li>
<li>$X\rightarrow\rightarrow Y\Rightarrow X\rightarrow\rightarrow (U-X-Y)$</li>
<li>$X\rightarrow Y\Rightarrow X\rightarrow\rightarrow Y$</li>
<li>$X\rightarrow\rightarrow Y,W\supseteq Z\Rightarrow W\cup X\rightarrow\rightarrow Y\cup Z$</li>
<li>$X\rightarrow\rightarrow Y,Y\rightarrow\rightarrow Z \Rightarrow X\rightarrow\rightarrow(Z-Y)$</li>
<li>$X\rightarrow\rightarrow Y,W\cap Y=\emptyset,W\rightarrow Z,Y\subseteq Z\Rightarrow X\rightarrow Z$</li>
</ul>
<h2 id="范式">范式<a href="#范式" class="anchor" aria-hidden="true"><i class="iconfont icon-link"></i></a></h2>
<ul>
<li>范式：满足允许存在的函数依赖的要求的关系集合</li>
<li>第一范式 $R\in$ 1NF：每个属性级都是不可分割的数据量
<ul>
<li>每个关系必须满足</li>
</ul>
</li>
<li>第二范式 $R\in$ 2NF: $R\in$ 1NF 且每个非主属性完全依赖于关键字
<ul>
<li>判断方法
<ul>
<li>确定主属性集合非主属性级</li>
<li>判断每个非主属性和关键字之间是否满足 2NF</li>
</ul>
</li>
</ul>
</li>
<li>第三范式 $R\in$ 3NF: $R\in$ 2NF 且每个非主属性不传递函数依赖于关键字</li>
<li>BCNF 范式：$R\in$ 1NF，若 $X\rightarrow Y$ 则 $X$ 必含有该关系模式的关键字
<ul>
<li>$R\in$ BCNF 则 $R\in$ 3NF</li>
</ul>
</li>
<li>第四范式 $R\in$ 4NF: $X\rightarrow\rightarrow Y$ 是非平凡多值依赖，则 $X$ 必含有关键字
<ul>
<li>$X\in$ BCNF</li>
</ul>
</li>
</ul>
<h2 id="模式分解">模式分解<a href="#模式分解" class="anchor" aria-hidden="true"><i class="iconfont icon-link"></i></a></h2>
<ul>
<li><strong>模式分解</strong>：将属性集合分解构成若干小的关系模式
<ul>
<li>找出不满足范式要求的函数依赖关系 $X\overset{f}{\rightarrow} Y$</li>
<li>分解为
<ul>
<li>$R_1=(X\cup Y,{X\rightarrow Y})$</li>
<li>$R_2=(\text{Head}(R)-Y, {A\rightarrow B|A\rightarrow B\in F^+,(A\cup B)\subseteq \text{Head}(R_2)})$</li>
</ul>
</li>
<li>对子关系重复进行</li>
<li>合并具有相同关键字的子关系模式</li>
</ul>
</li>
<li>无损联结性：分解后原关系中的信息不会被丢失 $R=R_1\Join R_2$
<ul>
<li>$R$ 的分解为 $\rho={R_1,R_2}$，$F$ 为 $R$ 所满足的函数依赖集合，分解 $\rho$ 具有无损联结性的充分必要条件是：$R_1\cap R_2\rightarrow (R_1-R_2)$ 或 $R_1\cap R_2\rightarrow (R_2-R_1)$</li>
</ul>
</li>
<li>依赖保持性：原有的函数依赖在分解后的关系模式上依然存在 $F^+=(F_1\cup F_2)^+$</li>
<li>在必须同时满足无损联接性和依赖保持性的要求下，一个关系模式最高可以被分解到满足第三范式</li>
</ul>

						</div>
					</main>
					<div class="d-none d-lg-block col-lg-3 bd-toc d-print-none">
						<div class="btn-group-vertical w-100 my-3">
    
    <a class="btn btn-outline-secondary text-dark w-100 p-2" href="https://list.html" target="_blank">
        <i class="iconfont icon-LC_icon_list_line"></i><br />待更新列表
    </a>
    

    
    <a class="btn btn-outline-secondary text-dark w-100 p-2" href="mailto:littlegreedy@qq.com"
        target="_blank">
        <i class="iconfont icon-discussion"></i><br />纠错与咨询
    </a>
    
    
    
    
        <a class="btn btn-outline-secondary text-dark w-100 p-2" href="#" onclick="window.print()">
            <i class="iconfont icon-dayin"></i><br />打印本页
        </a>
    
    
</div>
						<h4 class="card-title pb-0">目录</h4>
						<nav id="TableOfContents">
  <ul>
    <li><a href="#函数依赖fdfunctional-dependency">函数依赖（FD,Functional Dependency）</a></li>
    <li><a href="#多值依赖-mvd">多值依赖 (MVD)</a></li>
    <li><a href="#范式">范式</a></li>
    <li><a href="#模式分解">模式分解</a></li>
  </ul>
</nav>
						
						
						<div id="disqus_thread"></div>
							<script>
							

							

							(function() { 
							var d = document, s = d.createElement('script');
							s.src = "https://"+"your site name on disqus"+".disqus.com/embed.js";
							s.setAttribute('data-timestamp', +new Date());
							(d.head || d.body).appendChild(s);
							})();
							</script>
							<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>                  
					  	</div>
						
					</div>
				</div>
			</div>
		</div>
	</div>

	<script
    src="https://code.jquery.com/jquery-3.4.1.min.js"
    integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
    crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script><script defer src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.js" integrity="sha384-y23I5Q6l+B6vatafAwxRu/0oK/79VlbSz7Q9aiSZUvyWYIYsd+qj+o24G5ZU2zJz" crossorigin="anonymous"></script>
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/contrib/auto-render.min.js" integrity="sha384-kWPLUVMOks5AQFrykwIup5lo0m3iMkkHrD0uJ4H5cjeGihAutqP0yW0J6dpFiVkI" crossorigin="anonymous"
onload="renderMathInElement(document.body);"></script>

<script type="text/javascript" src="https://fziks.gitee.io/custom.min.d3e1b7647f32dbe7e0140398739a26dad3f3470fc1eebe0741ef33668f1b7bd0b2917dc6efb9f0d9f1092b91dca502cab1b883863f02530133a8a8ef609926af.js" integrity="sha512-0&#43;G3ZH8y2&#43;fgFAOYc5om2tPzRw/B7r4HQe8zZo8be9CykX3G77nw2fEJK5HcpQLKsbiDhj8CUwEzqKjvYJkmrw=="></script>
<script type="text/javascript">

document.addEventListener("DOMContentLoaded", function () {
    renderMathInElement(
        document.body, {
            delimiters: [
                {
                    left: "$$",
                    right: "$$",
                    display: true
                },
                {
                    left: "\\[",
                    right: "\\]",
                    display: true
                },
                {
                    left: "$",
                    right: "$",
                    display: false
                },
                {
                    left: "\\(",
                    right: "\\)",
                    display: false
                }
            ],
            strict: false
        }
    );
});


$(document).on('click', 'a[href^="#"]', function (event) {
    event.preventDefault();

    $('html, body').animate({
        scrollTop: $($.attr(this, 'href')).offset().top
    }, 500);
});
</script>




</body>

</html>